<template>
  <div class="goods-info">
    <div class="goodsimg">
      <van-swipe @change="onChange">
        <van-swipe-item><img :src="goods.img1"/></van-swipe-item>
        <van-swipe-item><img :src="goods.img2"/></van-swipe-item>
        <van-swipe-item><img :src="goods.img3"/></van-swipe-item>
        <van-swipe-item><img :src="goods.img4"/></van-swipe-item>
        <template #indicator>
          <div class="custom-indicator">{{ current + 1 }}/4</div>
        </template>
      </van-swipe>
    </div>
    <p>
      <span>￥{{ goods.originprice }}</span>
      <span class="sales">销量：{{ goods.sales }}</span>
    </p>
    <p>
      <span class="name">{{ goods.brand }}</span
      ><span class="category">{{ goods.category }}</span
      >{{ goods.proname }}
    </p>
  </div>
</template>
  
  <script>
import axios from "axios";
export default {
  name: "SecondsKill",

  data() {
    return {
      goods: {},
      comments: [],
      current: 0,
    };
  },
  created() {
    let proid = this.$route.params.goodsid;

    this.$service.get("api/pro/detail/" + proid).then((res) => {
      if (res.data.code == 200) {
        console.log("商品详情：", res.data.data);
        this.goods = res.data.data;
      }
    });
  },
  methods: {
    onChange(index) {
      this.current = index;
    },
  },

};
</script>
  <style scoped>
.goods-info {
  width: 100%;
  border-radius: 1rem;
  background-color: #fff;
  box-sizing: border-box;
  padding: 0 0.5rem;
}
.goodsimg {
  width: 100%;
  height: 25rem;
  overflow: hidden;
}
img {
  width: 100%;
}
.goods-info p {
  font-size: 0.9rem;
  font-weight: 800;
  padding-bottom: 1rem;
}
.goods-info p:nth-child(2) {
  color: red;
  font-size: 1.5rem;
  font-weight: normal;
  display: flex;
  justify-content: space-between;
}
.sales {
  color: black;
  font-size: 0.7rem;
  line-height: 1.5rem;
}
.name {
  color: white;
  background-color: red;
  border-radius: 0.1rem;
  padding: 0 0.2rem;
}
.category {
  color: white;
  background-color: rgb(34, 0, 255);
  border-radius: 0.1rem;
  margin: 0 0.5rem;
  padding: 0 0.2rem;
}
.custom-indicator {
    position: absolute;
    right: 5px;
    bottom: 5px;
    padding: 2px 5px;
    font-size: 12px;
    background: rgba(0, 0, 0, 0.1);
  }
</style>
  
  